/**
 * @Author @fiber-cloud
 * @Date 2025/8/21 20:06
 * 多线程——读取多线程状态
 */
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 10000000; j++) {
                    int a = 0;
                    a += 10;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        //在启动之前先获取一下线程t的状态，这里其实就是New状态
        System.out.println("start之前："+t.getState());

        t.start();

        for (int i = 0; i < 1000; i++) {
            System.out.println("t在执行过程中的状态："+ t.getState());
        }
        t.join();

        System.out.println("t结束之后的状态："+ t.getState());
    }
}
